package org.jfonia.connect5.numerical;

import org.jfonia.connect5.basics.BasicValueNode;
import org.jfonia.connect5.relations.ABRelation;

/**
 * @author wijnand.schepens@hogent.be
 */
public class ConstantDistanceRelation extends ABRelation<Integer, Integer>
{
	int distance;

	public ConstantDistanceRelation(BasicValueNode<Integer> a, BasicValueNode<Integer> b, int distance)	// assure b = a + distance
	{
		super(a, b);
		this.distance = distance;
	}


	public void updateB()
	{
		b.setValue(a.getValue() + distance, this);
	}

	public void updateA()
	{
		a.setValue(b.getValue() - distance, this);
	}

}
